<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<?php include("mainlist.php");?>

<table class="reference" cellspacing="0" border="0" width="995">
	<tr>
		<td width="200" valign="top">					
			<?php
				include("menuleftcategory.php");
			?>
		</td>	
		<td width="795">
			<form action="index.php?admin=productAdmin&do=formaddcategory" method="post" enctype="multipart/form-data">
				<table cellspacing="0" border="0" width="790">
					<tr>
						
						<td width="790" class="title_manager_cate">Tạo danh mục sản phẩm</td>
					
					</tr>
				</table>
				<table class="reference" cellspacing="0" border="1" width="100%"> 
					<tr>
						<td colspan="2" align="center">
							<?php
								$cateName=$_POST['cateName'];
								$description=$_POST['description'];
								if(isset($_POST['submit'])){
									if($cateName==''){
										echo "<span class=\"error_message\">Bạn phải nhập vào tên danh mục sản phẩm.</span>";
									}
								
									if($cateName!=''){
										$query="INSERT INTO categories(cateName,description) VALUES ('$cateName','$description')";
										mysql_query($query);
										echo "Thêm danh mục sản phẩm thành công.";
										echo "<script>window.location='index.php?admin=productAdmin&do=listproduct'</script>";
									}
								}	
							?>	
						</td>
					</tr>	
					<tr>
						<td width="300"><b>Tên danh mục:</b></td>
						<td width="400">
							<input type="text" name="cateName" size="40" /> <font color="#FF0000"> * </font>
						</td>
					</tr>
					
				   <tr> 
						<td width="300"><b>Mô tả:</b></td>
						<td>
							<textarea name="description" rows="20" cols="20"></textarea>
						</td>
				   </tr>
				   <tr>
						<td></td>
						<td>
							<input type="submit" name="submit" value="Tạo mới danh mục" />
							<input type="reset" name="reset" value="Nhập lại" />
							<input type="button" name="Cancel" value="Cancel" onclick="window.location = 'index.php?admin=productAdmin&do=listproduct' " /> 
						<td>
				   </tr>
				</table>
			</form>
		</td>
	</tr>	
</table>
</body>
</html>